package com.github.jin.simpledropdownmenu

import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import kotlinx.android.synthetic.main.activity_main.*
import org.jetbrains.anko.toast

class MainActivity : AppCompatActivity(),
        SimpleDropDownMenu.OnDropDownMenuOpenStateListener,
        SimpleDropDownMenu.OnMenuItemClickListener {

    override fun dropDownMenuStateChanges(menuOpenState: Boolean) {

    }

    override fun onMenuItemClickListener(position: Int) {
        toast("点击第 $position 项")
    }

    private var mMenuItemList = mutableListOf<MenuItem>()
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        this.simple_drop_menu.addMenuItem(mMenuItemList)
        this.simple_drop_menu.dropDownMenuOpenStateListener = this
        this.simple_drop_menu.menuItemClickListener = this
    }

    init {
        mMenuItemList.add(MenuItem(R.drawable.ic_user, "Jin"))
        mMenuItemList.add(MenuItem(R.drawable.ic_setting, "Setting"))
        mMenuItemList.add(MenuItem(R.drawable.ic_privacy_settings, "Privacy"))
        mMenuItemList.add(MenuItem(R.drawable.ic_log_out, "Logout"))
    }
}
